//! 库根模块测试
//! 
//! 测试 src/lib.rs 中的 DataForge 主要功能

use dataforge::{DataForge, Language};

#[test]
fn test_dataforge_creation() {
    let forge = DataForge::new(Language::ZhCN);
    assert!(forge.generate("uuid_v4").is_some());
}

#[test]
fn test_dataforge_builtin_generators() {
    let forge = DataForge::new(Language::ZhCN);
    
    // 测试内置生成器
    assert!(forge.generate("uuid_v4").is_some());
    assert!(forge.generate("zh_cn_name").is_some());
    assert!(forge.generate("en_us_name").is_some());
}

#[test]
fn test_dataforge_custom_generator() {
    let mut forge = DataForge::new(Language::ZhCN);
    forge.register("test_gen", || serde_json::Value::String("test".to_string()));
    
    let result = forge.generate("test_gen");
    assert_eq!(result, Some(serde_json::Value::String("test".to_string())));
}

#[test]
fn test_dataforge_nonexistent_generator() {
    let forge = DataForge::new(Language::ZhCN);
    assert!(forge.generate("nonexistent").is_none());
}

#[test]
fn test_dataforge_different_languages() {
    let languages = vec![Language::ZhCN, Language::EnUS, Language::JaJP];
    
    for lang in languages {
        let forge = DataForge::new(lang);
        assert!(forge.generate("uuid_v4").is_some());
    }
}

#[test]
fn test_dataforge_generator_override() {
    let mut forge = DataForge::new(Language::ZhCN);
    
    // 覆盖内置生成器
    forge.register("uuid_v4", || serde_json::Value::String("custom-uuid".to_string()));
    
    let result = forge.generate("uuid_v4");
    assert_eq!(result, Some(serde_json::Value::String("custom-uuid".to_string())));
}